
/**
* @module create-readitem
* @author: Hjava
* @description: 创建已读时间模块
* @since: 2018-07-23 12:32:56
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.createPubReadProtocol = exports.createIMReadProtocol = void 0;
var userData_1 = __webpack_require__(/*! _util/userData */ "./src/core/utils/userData.ts");
var constant_1 = __webpack_require__(/*! _util/constant */ "./src/core/utils/constant.ts");
function createIMReadProtocol(_a) {
    var _b = _a.uid, uid = _b === void 0 ? userData_1.default.get('uid') : _b, _c = _a.uuid, uuid = _c === void 0 ? void 0 : _c, _d = _a.readData, readData = _d === void 0 ? [] : _d, sessionType = _a.sessionType;
    if (true) {
        var IM_1 = __webpack_require__(/*! _core/im */ "./src/core/im/index.ts").default;
        var readItems = readData.map(function (_a) {
            var chatId = _a.chatId, channelId = _a.channelId, _b = _a.sid, sid = _b === void 0 ? undefined : _b, sessionType = _a.sessionType, peerAppId = _a.peerAppId, svrTime = _a.svrTime, time = _a.time;
            if (sid) {
                return new IM_1.Session.IMSyncReadItem2({
                    chatId: chatId,
                    channel: channelId,
                    type: (sessionType === constant_1.SESSION_TYPE.CHAT2 ? constant_1.CHAT_TYPE.CHAT_TYPE_ONE_VS_ONE : constant_1.CHAT_TYPE.CHAT_TYPE_GROUP),
                    peerAppId: peerAppId,
                    stamp: time,
                    sts: svrTime,
                    sid: sid
                });
            }
            else {
                return new IM_1.Session.IMSyncReadItem({
                    chatId: chatId,
                    channel: channelId,
                    type: (sessionType === constant_1.SESSION_TYPE.CHAT ? constant_1.CHAT_TYPE.CHAT_TYPE_ONE_VS_ONE : constant_1.CHAT_TYPE.CHAT_TYPE_GROUP),
                    peerAppId: peerAppId,
                    stamp: time,
                    sts: svrTime
                });
            }
        });
        if (sessionType === constant_1.SESSION_TYPE.CHAT2) {
            return new IM_1.Session.IMSyncRead2({
                uid: uid,
                msgUuid: uuid,
                syncReadItems: readItems
            });
        }
        {
            return new IM_1.Session.IMSyncRead({
                uid: uid,
                msgUuid: uuid,
                syncReadItems: readItems
            });
        }
    }
}
exports.createIMReadProtocol = createIMReadProtocol;
function createPubReadProtocol(_a) {
    var _b = _a.uid, uid = _b === void 0 ? userData_1.default.get('uid') : _b, _c = _a.uuid, uuid = _c === void 0 ? void 0 : _c, _d = _a.readData, readData = _d === void 0 ? [] : _d, sessionType = _a.sessionType;
    if (true) {
        var PUB_1 = __webpack_require__(/*! _core/pub */ "./src/core/pub/index.ts").default;
        var readItems = readData.map(function (_a) {
            var chatId = _a.chatId, peerUid = _a.peerUid, channelId = _a.channelId, _b = _a.sid, sid = _b === void 0 ? undefined : _b, sessionType = _a.sessionType, peerAppId = _a.peerAppId, svrTime = _a.svrTime, time = _a.time;
            if (sid) {
                return new PUB_1.Session.PubSyncReadItem2({
                    chatId: chatId,
                    peerUid: peerUid,
                    peerAppId: peerAppId,
                    channel: channelId,
                    type: (sessionType === constant_1.SESSION_TYPE.PUB_CHAT2 ? constant_1.CHAT_TYPE.CHAT_TYPE_PUB : constant_1.CHAT_TYPE.CHAT_TYPE_CS),
                    stamp: time,
                    sts: svrTime,
                    sid: sid
                });
            }
            else {
                return new PUB_1.Session.PubSyncReadItem({
                    chatId: chatId,
                    peerUid: peerUid,
                    peerAppId: peerAppId,
                    channel: channelId,
                    type: (sessionType === constant_1.SESSION_TYPE.PUB_CHAT ? constant_1.CHAT_TYPE.CHAT_TYPE_PUB : constant_1.CHAT_TYPE.CHAT_TYPE_CS),
                    stamp: time,
                    sts: svrTime,
                });
            }
        });
        if (sessionType === constant_1.SESSION_TYPE.PUB_CHAT2 || sessionType === constant_1.SESSION_TYPE.CS_CHAT2) {
            return new PUB_1.Session.PubSyncRead2({
                uid: uid,
                msgUuid: uuid,
                syncReadItems: readItems
            });
        }
        else {
            return new PUB_1.Session.PubSyncRead({
                uid: uid,
                msgUuid: uuid,
                syncReadItems: readItems
            });
        }
    }
}
exports.createPubReadProtocol = createPubReadProtocol;


//# sourceURL=webpack://MTDX/./src/extra/utils/create-readitem.ts?